package sevensoft.创建型模式.工厂模式.反射工厂.factory;

import sevensoft.创建型模式.工厂模式.反射工厂.guns.Gun;

import java.lang.reflect.InvocationTargetException;

public class SimpleGunFactory {
    public <T extends Gun> Gun createGun(Class<T> gunClass) {
        try {
            return gunClass.getConstructor(null).newInstance();
        }
        catch (InvocationTargetException | InstantiationException | IllegalAccessException |
               NoSuchMethodException e) {
            throw new RuntimeException(e);
        }

    }
}
